package com.geetour.columbus.customer.bo.impl;

import java.util.Calendar;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.geetour.columbus.common.exceptions.BOException;
import com.geetour.columbus.common.model.C.Account;
import com.geetour.columbus.common.utils.DateUtils;
import com.geetour.columbus.customer.bo.IAccountBO;
import com.geetour.columbus.customer.dao.IAccountDAO;

@Service
public class AccountBOImpl implements IAccountBO {

	private IAccountDAO accountDAOImpl;

	@Autowired
	public void setAccountDAOImpl(IAccountDAO accountDAOImpl) {
		this.accountDAOImpl = accountDAOImpl;
	}

	@Override
	public Account findAccountById(Long id) throws BOException {
		return accountDAOImpl.findAccountById(id);
	}

	@Override
	public int insertAccount(Account account) throws BOException {
		if (account == null) {
			return -1;
		}
		account.setModifydate(DateUtils.formatDate(Calendar.getInstance().getTime(), DateUtils.format));
		account.setCreatedate(DateUtils.formatDate(Calendar.getInstance().getTime(), DateUtils.format));
		return accountDAOImpl.insertAccount(account);
	}

	@Override
	public int updateAccount(Account account) throws BOException {
		return accountDAOImpl.updateAccount(account);
	}
}
